<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/TemplateUser.Master" Inherits="System.Web.Mvc.ViewPage" %>
<%@ Import Namespace="ManageBanking.Models" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">

   <script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>

    <script src="../../Scripts/functions.js" type="text/javascript"></script>

    <script src="../../Scripts/wysiwyg.js" type="text/javascript"></script>

    <link href="../../Content/css/SucErr1.css" rel="stylesheet" type="text/css" />
     <style type="text/css">
      
        .green

        {
            float:left;
            color: Green;
            margin-left:218px;
            margin-top:-9px;
        }

        .red

        {   float:left;
            margin-left:218px;
            color: Red;
            margin-top:-9px;
        }
        #divcheck
        {
        float:left;
        margin-left:14px;
        margin-top:-9px;	
        }
        .btnCheck
        {
        margin-left:11px;	
        	
        }
    </style>
    <script type="text/javascript">

        $(document).ready(function() {
            var a = 0;
            $("#oldpassword").keyup(function() {
                var status = $("#divcheck");
                status.html("");
                $("#a").attr("value", 0);
            });
            $("#oldpassword").blur(function() {

            var name = $("#oldpassword").val();

                var status = $("#divcheck");

                status.html("Checking....").removeClass(); ;

                $.post("/Admin/ManageUserAdmin/CheckOldPassword", { oldpassword: name },

                    function(data) {

                        if (data == true) {

                            status.html("Password is Correct!").addClass("green");
                            $("#a").attr("value", 1);

                        } else {

                            status.html("Password Is Not  Correct!").addClass("red");
                            $("#a").attr("value", 0);
                        }

                    });

            });

            $('#f1').submit(function() {
                a = $('#a').attr("value");
                if (a == 0) {
                    alert("Please Check Old Password,Or OldPassword not valid");
                    return false;

                }
                if (a == 1)
                    return true;
                return false;
            });


        });
    </script>

    
	<script language="javascript" type="text/javascript">
	    $(document).ready(function() {

	        $('#f1').validate({
	            rules: {
	                oldpassword: {
	                    required: true
	                },
	                newpassword: {
	                    required: true,
	                    minlength: 6,
	                    maxlength: 15
	                },
	                confirmnewpassword: {
	                    equalTo: "#newpassword"
	                }
	            }, //ket thuc rules
	            messages: {
	                oldpassword: {
	                    required: "Old Password not null!!!"
	                },
	                newpassword: {
	                    required: "New Password not null!!!",
	                    minlength: "New Password is greater than 6 characters",
	                    maxlength: "New Password is less than 6 characters"
	                },
	                confirmnewpassword: {
	                    required: "Confirm New Password isn't same New Password"
	                }
	            }
	        });  // ket thuc validate

	        $('#oldpassword').keyup(function() {
	            $('#messge_error').html("");
	        });


	    });           // ket thuc ready
    </script>
	
	
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">


    <div class="center_block_top"><span>&nbsp;</span><h3>Change Password</h3></div>
<div class="center_block_mau"><!--section-->
	<div id="intro">
<blockquote>
 <% if (ViewData["Check"] == "true")
              {
                  %>
         <div class="succes">
					<div class="succes_icon"><!-- --></div>
					<a href="#" class="close" title="Close this notification">x</a>
					<div class="desc">
						<span>Success!</span>
						<p>Your Action Is Success</p>
					</div>
				</div>
				<div class="clear"><!-- --></div>   
				<%} %>
				<%else if (ViewData["Check"]!=null){ %>
				<div class="err">
					<div class="err_icon"><!-- --></div>
					<a href="#" class="close" title="Close this notification">x</a>
					<div class="desc">
						<span>Error!</span>
						<p><%=ViewData["Check"]%></p>
					</div>
				</div>
				<%} %>
  <div class="redistry">
        <% 
    Username ac = (Username)Session["Login"];
    using (Html.BeginForm("ResolveChangePassword", "ManageUser", FormMethod.Post, new { @id = "f1" }))
    {
        %>
  		<ul>
        	<li>
            	<span>OldPassword:</span>
            	<div class="input_text"></div>
            	<div><input name="oldpassword" id="oldpassword" type="password" size="20"/>
                <input id="Hidden1" name ="idaccount" value="<%=ac.IdUsername %>" type="hidden" />
            	</div>
            	<div></div>
                <input id="a" type="hidden" />
                
                <div id="divcheck" class="error" visible="true"></div>
            	</li>
            <li>
            	<span>New Password:</span>
            	<div class="input_text"></div>
            	<div><input type="password" size="20" id="newpassword" name="newpassword" /></div></li>
            <li>
            	<span>Confirm New Password:</span>
            	<div class="input_text"></div>
            	<div><input  type="password" size="20" id="confirmnewpassword" name="confirmnewpassword" /></div></li>
        		
            <li>
            	<span>&nbsp;</span>
                <ul>
                	<li ><input type="submit" value="OK" class="ok"/></li>
                    <li id="cancel" ><input type="reset" value="Reset" class="ok" name="cancel" /></li>
                </ul></li> 
               
        </ul>
        <%} %>
  </div>
</blockquote>
<div class="clearBoth"></div>
<blockquote>
 
</blockquote>
</div>
<!--//intro-->
</div><!--//section-->
<div class="center_block_bottom_mau"></div>

</asp:Content>
